/**
 * @Author：ming
 * @Date：2023/10/4 8:18 PM
 * @Filename：Lc820
 */

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author ming
 */
public class Lc820 {
    public int minimumLengthEncoding(String[] words){
        Arrays.sort(words, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o2.length()-o1.length();
            }
        });
        StringBuilder sb = new StringBuilder();
        String s = sb.toString();
        for (int i = 0; i < words.length; i++) {

             s = words[i]+"#";
            if(sb.toString().contains(s)){
                continue;
            }else {
                sb.append(s);
            }
        }
        return sb.toString().length();
    }
}
